package com.gao.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class Receive {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket(9999);
        DatagramPacket packet = new DatagramPacket(new byte[1024],1024);
        datagramSocket.receive(packet);
         byte[] data = packet.getData();
         String msg = new String(data,0,packet.getLength());
         datagramSocket.close();
        System.out.println(msg);
    }
}
